package com.dixon.worddayday.util;

import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

public class CurveFactory {
    static String DEFUAL_CACHE = "DEFUAL";
    static Map<String, IForgettingCurve> cache = new HashMap<>();

    public static IForgettingCurve getCurve(String intervals) {
        String key = StringUtils.isEmpty(intervals) ? DEFUAL_CACHE : intervals;

        IForgettingCurve iForgettingCurve = cache.get(key);
        if(iForgettingCurve == null) {
            iForgettingCurve = new EbbinghausCurve(intervals);
            cache.put(key, iForgettingCurve);
        }

        return iForgettingCurve;
    }
}
